package com.qingzhuge.scheduler.dao;

import com.qingzhuge.dao.BasePkLongDao;
import com.qingzhuge.scheduler.entity.SysTaskScheduled;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * @author : zero.xiao
 * @description :
 * @date :2019-05-17 14:34
 * @modified :
 */
public interface SysTaskScheduledDao extends BasePkLongDao<SysTaskScheduled> {
    /**
     * 查询出TaskJobKey#id,taskName,taskGroup
     * @param id ID
     * @return SysTaskScheduled#id,taskName,taskGroup
     */
    @Query("select new SysTaskScheduled(s.id,s.taskName,s.taskGroup) from SysTaskScheduled s where s.id = ?1")
    SysTaskScheduled findTaskJobKeyById(Long id);

    /**
     * 修改任务状态
     * @param id 任务id
     * @param status 任务状态
     */
    @Modifying
    @Query("update SysTaskScheduled u set u.status = :status where u.id = :id")
    void updateStatus(@Param("id") Long id,@Param("status") Integer status);
}
